const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
//const session = require("express-session");
//const MWView = require("./busniess/module_view");
//const MWLogin = require("./busniess/module_login");
//const MWEdit = require("./busniess/module_edit");
//const MWSearch = require("./busniess/module_search");

class HTMLServer {
    constructor(port) {
        this.mainApp = express();
        this.mainApp.use(express.static("./"));
        this.mainApp.use(express.static("../themes/default/"));
        this.mainApp.use(express.static("../client/"));
        this.mainApp.use(express.static("../www/third/"));
        this.mainApp.use(express.static("../www/themes/default/"));
        //this.mainApp.post("/search", bodyParser.json({extended: false, limit: "1mb"}), MWSearch.post);
        //this.mainApp.use(cookieParser('singedMyCookie'));
        //this.mainApp.post("/", bodyParser.json({extended: false, limit: "1kb"}), MWView.PostArticle);
        //this.mainApp.get("/notebook", MWView.GetNotebook);
        //this.mainApp.post("/notebook/list", MWView.PostNotebookList);
        //this.mainApp.post("/notebook", bodyParser.json({extended: false, limit: "1kb"}), MWView.PostArticle);
        //this.mainApp.get("/article", MWView.GetArticle);
        //this.mainApp.get("/code", MWView.GetCode);
        //this.mainApp.post("/history", MWView.PostHistory);
        //this.mainApp.get("/projects", MWView.GetProjects);
        //this.mainApp.get("/editor", MWView.GetEditor);
        //this.mainApp.use(session({
            //secret: 'sig#^#$SFWGE++|@^!>>>.aap',
            //name: 'session_id',
            //resave: true,
            //saveUninitialized: true,
            //cookie: {
                //maxAge: 1000 * 30 * 60    /*30min*/
            //},
            //rolling: true,//在每次请求时强行设置 cookie，这将重置 cookie 过期时间（默认：false）
        //}))
        //this.mainApp.get("/edit", MWEdit.get);
        //this.mainApp.post("/edit", bodyParser.json({extended: false, limit: "1mb"}), MWEdit.post);
        //this.mainApp.get("/login", MWLogin.get);
        //this.mainApp.post("/login", bodyParser.json({extended: false, limit: "1kb"}), MWLogin.post);

        this.mainApp.listen(port, () => console.log(`HTTP server is now listening port: ${port}`));
    }
}

const htmlServer = new HTMLServer(8082);
